#ifndef IODEF_H_
#define IODEF_H_

#include <stdint.h>

#define __I   volatile const
#define __O   volatile
#define __IO  volatile

#define _BIT(__n)       (1<<(__n))
#define _MASK(__n,__s)  (((1<<(__s))-1)<<(__n))
#define _VALUE(__n,__v) ((__v)<<(__n))

#define readb(_register_)       \
        (*((volatile uint8_t *)(_register_)))

#define readw(_register_)       \
        (*((volatile uint16_t *)(_register_)))

#define readl(_register_)       \
        (*((volatile uint32_t *)(_register_)))

#define writeb(_register_, _value_)     \
        do { *((volatile uint8_t *)(_register_)) = (_value_); }while(0)

#define writew(_register_, _value_)     \
        do { *((volatile uint16_t *)(_register_)) = (_value_); }while(0)

#define writel(_register_, _value_)     \
        do { *((volatile uint32_t *)(_register_)) = (_value_); }while(0)

#endif /* IODEF_H_ */
